home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3 (Developer)…68k, x86, SPARC, PA-RISC] / NeXTSTEP 3.3 Dev Intel.iso / usr / sybase / doc / dbrettype.man < prev    next >
Text File  |  1993-04-22  |  6KB  |  155 lines

  1.  
  2.   1                       Version 4.0 -- 5/1/89                dbrettype
  3.   ______________________________________________________________________
  4.  
  5.   NAME:  dbrettype
  6.  
  7.   FUNCTION:
  8.        Determine the datatype of a return parameter value generated by a
  9.        stored procedure.
  10.  
  11.   SYNTAX:
  12.        int dbrettype(dbproc, retnum)
  13.  
  14.        DBPROCESS *dbproc;
  15.        int       retnum;
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.   dbrettype               Version 4.0 -- 5/1/89                        2
  25.   ______________________________________________________________________
  26.  
  27.   COMMENTS:
  28.  
  29.        o dbrettype() returns the datatype of a  return  parameter  value
  30.          generated  by  a stored procedure.  It is useful in conjunction
  31.          with remote procedure calls and EXECUTE  statements  on  stored
  32.          procedures.
  33.        o Transact-SQL stored procedures can return values for  specified
  34.          "return  parameters."  Changes  made  to  the value of a return
  35.          parameter inside the stored procedure are then available to the
  36.          program  that  called  the procedure.  This is analogous to the
  37.          "pass by reference"  facility  available  in  some  programming
  38.          languages.
  39.  
  40.          For a parameter to function as a return parameter, it  must  be
  41.          declared  as  such  within  the  stored procedure.  The EXECUTE
  42.          statement or remote procedure call that calls the  stored  pro-
  43.          cedure must also indicate that the parameter should function as
  44.  
  45.  
  46.   3                       Version 4.0 -- 5/1/89                dbrettype
  47.   ______________________________________________________________________
  48.          a return parameter.  In the case of a remote procedure call, it
  49.          is  the dbrpcparam() routine that specifies whether a parameter
  50.          is a return parameter.
  51.  
  52.        o When executing a  stored  procedure,  the  server  returns  any
  53.          parameter values immediately after returning all other results.
  54.          Therefore, the application can call dbrettype() only after pro-
  55.          cessing  the stored procedure's results by calling dbresults(),
  56.          as well as dbnextrow() if appropriate.   (Note  that  a  stored
  57.          procedure  can  generate  several  sets of results-one for each
  58.          SELECT it contains.  Before the  application  can  call  dbret-
  59.          type() or any other routines that process return parameters, it
  60.          must call dbresults() and dbnextrow() as many times  as  neces-
  61.          sary to process all the results.)
  62.        o If the stored procedure is  invoked  with  a  remote  procedure
  63.          call,  the  return parameter values are automatically available
  64.          to  the  application.   If,  on  the  other  hand,  the  stored
  65.  
  66.  
  67.  
  68.   dbrettype               Version 4.0 -- 5/1/89                        4
  69.   ______________________________________________________________________
  70.          procedure is invoked with  an  EXECUTE  statement,  the  return
  71.          parameter  values  are available only if the command batch con-
  72.          taining the EXECUTE statement uses local  variables,  not  con-
  73.          stants, for the return parameters.
  74.  
  75.        o dbrettype() actually returns an integer  token  value  for  the
  76.          datatype  (SYBCHAR, SYBFLT8, etc.).  To convert the token value
  77.          into  a  readable  token  string,  use  dbprtype().   See   the
  78.          dbprtype() manual page for a list of all token values and their
  79.          equivalent token strings.
  80.        o For a list of SQL Server datatypes, see  the  manual  page  for
  81.          types.
  82.  
  83.        o Other  routines  return  additional  information  about  return
  84.          parameter values:
  85.           o dbnumrets() returns the total  number  of  return  parameter
  86.             values.
  87.  
  88.  
  89.  
  90.   5                       Version 4.0 -- 5/1/89                dbrettype
  91.   ______________________________________________________________________
  92.  
  93.           o dbretdata() returns a pointer to a parameter value.
  94.           o dbretlen() returns the length of a parameter value.
  95.  
  96.           o dbretname() returns the name of a parameter value.
  97.        o For an example of this routine, see Example 8 in the DB-Library
  98.          Reference Supplement.
  99.  
  100.   PARAMETERS:
  101.        dbproc -  A pointer to the DBPROCESS structure that provides  the
  102.            connection for a particular front-end/SQL Server process.  It
  103.            contains all the information that DB-Library uses  to  manage
  104.            communications and data between the front end and SQL Server.
  105.        retnum -  The number of the return parameter value  of  interest.
  106.            The first return value is 1.  Values are returned in the same
  107.            order as the parameters  were  originally  specified  in  the
  108.            stored  procedure's  CREATE  PROCEDURE statement.  (Note that
  109.  
  110.  
  111.  
  112.   dbrettype               Version 4.0 -- 5/1/89                        6
  113.   ______________________________________________________________________
  114.            this is not necessarily the same order as  specified  in  the
  115.            remote  procedure  call.)  When specifying retnum, non-return
  116.            parameters do not count.  For example, if the second  parame-
  117.            ter  in  a stored procedure is the only return parameter, its
  118.            retnum is 1, not 2.
  119.  
  120.   RETURNS:
  121.        A token value for the datatype of the specified return value.
  122.  
  123.        In a few cases, the token value returned by this routine may  not
  124.        correspond exactly with the column's SQL Server datatype:
  125.        o SYBVARCHAR is returned as SYBCHAR.
  126.  
  127.        o SYBVARBINARY is returned as SYBBINARY.
  128.        o SYBDATETIMN is returned as SYBDATETIME.
  129.  
  130.        o SYBMONEYN is returned as SYBMONEY.
  131.  
  132.  
  133.  
  134.   7                       Version 4.0 -- 5/1/89                dbrettype
  135.   ______________________________________________________________________
  136.        o SYBFLTN is returned as SYBFLT8.
  137.  
  138.        o SYBINTN is returned as SYBINT1, SYBINT2, or SYBINT4,  depending
  139.          on the actual type of the SYBINTN.
  140.       If retnum is out of range, -1 is returned.
  141.  
  142.   SEE ALSO:
  143.        dbnextrow, dbnumrets, dbprtype, dbresults,  dbretdata,  dbretlen,
  144.        dbretname, dbrpcinit, dbrpcparam
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.